package de.haw.shc.JSONObjects;

import android.util.Log;
import de.haw.shc.Interfaces.DeviceProperty.iCurtain;
import de.haw.shc.Action.Actions;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: mizus
 * Date: 08.05.13
 * Time: 15:23
 * To change this template use File | Settings | File Templates.
 */
public class Curtain implements iCurtain {

    private String name, id, raum, viewName, viewRaumName;

    public Curtain(){
    }

    @Override
    public JSONObject createOpenCurtain(){
           Map<String, String> valMap = createValMap(name+ "open");
           JSONObject jsonObject = new JSONObject(valMap);
           Log.d("CurtainOpen", jsonObject.toString());
           return jsonObject;
    }

    @Override
    public JSONObject createCloseCurtain(){
           Map<String, String> valMap = createValMap(name + "close");
           JSONObject jsonObject = new JSONObject(valMap);
           Log.d("CurtainOpen", jsonObject.toString());
           return jsonObject;
    }


    private Map<String, String> createValMap(String curtainAction) {
        Map<String,String> result = new HashMap<String, String>();
        result.put("action", curtainAction);
        result.put("client_id", "Timo_Stephan");
        result.put("Version", null);
        return result;
    }


    @Override
    public String getName() {
        return name;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getID() {
        return id;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setRaum(String aRaum) {
       raum = aRaum;//To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getRaum() {
        return raum;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setName(String name) {
       this.name = name;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setID(String ID) {
        id = ID;//To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isColorPicker() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setColorable(boolean bool) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setViewName(String name) {
        viewName = name;//To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getViewName() {
        return viewName;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setViewRaumName(String name) {
        viewRaumName = name;    //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getViewRaumName() {
        return viewRaumName;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isWindow() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isBlind() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isLight() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isRadiator() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isCurtain() {
        return true;
    }

    @Override
    public JSONObject deactivate() {
        return this.createCloseCurtain();  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public JSONObject activate(){
        return this.createCloseCurtain();
    }

    @Override
    public String getDeviceControll() {
        return Actions.CURTAINCONTROL;  //To change body of implemented methods use File | Settings | File Templates.
    }


    @Override
    public String toString(){
        return "Name: " + getViewName() + " Room: "+ getViewRaumName();
    }

}
